1. Field of the Invention
The present invention relates to a file management method for a storage medium accessed from a processor, and in particular, relates to a file management method suitable for a storage medium having a limitation on the number of times data is erased.
2. Description of the Related Art
A computer file system that stores data in a storage medium on a file-by-file basis mediates to store a file in various media. For example, flash memory that is suitable for increasing capacity, is electrically rewritable, does not lose data if the power source is turned off, and is used to store files. Though data can be written into the flash memory in small units, such as a byte, the written data must be erased in large units, like a block.
Then, there is a limitation on the number of times data in the flash memory is erased. Therefore, when a flash memory is used as a storage medium, the flash memory is used in such a way that the numbers of erase operations for each block are equalized, to extend a usable period as long as possible. The equalization of the number of erasing times is called “wear leveling”.
In the file system using a flash memory as a storage medium, like a JFFS (Journaling Flash File System) by David Woodhouse, the technique of “log-structured” (Uresh Vahalia, “UNIX Internals: The New Frontiers”, Perason Education Japan, May 15, 2000, pp. 398 to 399) is used.
“Log-structured” is a data storing method in which data is continuously added and stored one after another without being overwritten. According to this method, the old data remains stored in a log structured array among data that are continuously stored. Then, the remaining data that are stored in a log structured array contain both valid and invalid data. Therefore, according to the “log-structured” file system, like JFFS, in the mount process that is executed at the start of use, all data in flash memory are read, and a range of significant data is identified. In the “log-structured” technique, like this, since data is not locally erased, the blocks of data can be used equally.
However, the above-mentioned conventional technique has the following problem.
According to the “log-structured” file system, the number of erase operations in a storage area can be equalized and the usable period can be prolonged. However, in such a file system, since it is necessary to check all data in the storage medium to be mounted and to screen out a valid data range in order to find a front log in the mount process. There is a problem that the process is lengthy and it takes much time at the start of the operation.
As another conventional file system, there is a file system in which a file management structure is recorded in an index file to recognize the entire structure easily. As such a file system, there is a LFS (Logstructured File System) of 4.4BSD (Berkeley Software distribution.) For example, see Marshall Kirk Mckusick, Keith Bostic, Michael J. kareles, Johon S. Quarterman, “The Design and Implementation of the 4.4BSD”, Oct. 10, 2003, pp. 331 to 350.
However, in the LFS, though the position of the index file changes in the storage madium, the management information showing the position of the index file is recorded in the superblock whose the position is fixed. Therefore, the contents of the superblock are updated whenever the position of the index file changes through update.
Therefore, the number of erase operations in the block used as the superblock is larger than the number of erase operations in another block, and therefore the number of erasing times is not equalized. Accordingly, the entire usable period of the flash memory is determined by the number of erasing times in the superblock.